<?php

namespace App\Http\Controllers\mobile;

use App\Models\Category;
use App\Models\Book;

class CategoryController extends BaseController {
	
	public function show($order) {
		$ctOrder = (int)$order;
		$category = Category::where('order', (int)$order)->first();
		if(is_null($category)) {
			return redirect('/mobile/404');
		}
		$books = Book::select(['id', 'name', 'author', 'abstract', 'clicks', 'font_num', 'thumbnail'])
				->where('category_id', $category->id)
				->orderBy('clicks', 'DESC')->take(30)->get();
		return view('mobile.index', compact('books', 'ctOrder'));
	}
}
